<?php
require '../config.php';

$idcliente = $_REQUEST['idcliente'];
$deDonde = $_REQUEST['dedonde'];

if ($idcliente == null OR $idcliente == 0 OR empty($idcliente) )
{
	echo("<h3>Acceso negado :(</h3>");
	exit();
} 
$query="SELECT * FROM clientes WHERE idclientes = '".$idcliente."'";
$resultset = mysql_query($query,$conexion);


if(!$resultset)
{
	mysql_close();
	echo json_encode('Error en el query: ' . mysql_error());
}
elseif(!mysql_num_rows($resultset))
{
	mysql_close();
	echo json_encode('Sin resultados');
}
else
{
	$row = mysql_fetch_assoc($resultset);
	echo   "<table class='table table-bordered'>";
	echo   "<tbody>";
	echo   "<tr>";
	echo   "<td>";
	echo "<form id='formulario' name='formulario'  style='background-color: #f2f9f2; text-align:left'>";
	echo "<div class='form_description'>";
	echo "<h2>Registro de llamada al cliente.</h2>";
	echo "<ul>";
	echo "<li id='li_4' >";
	
	echo "<div>";
	echo "<label class='description' for='cedulaver'>C&eacute;dula </label>";
	echo "<input id='cedulaver' disabled type='text'  size='50' value='".$row['cedula']."'>";
	echo "<input id='cedulah' type='hidden' value='".$row['cedula']."' />";
	echo "</div>";
	
	echo "<div>";
	echo "<label class='description' for='nombrever'>Nombre del cliente: </label>";
	echo "<input id='nombrever'  disabled   type='text'  size='50' value='".$row['nombres']." ".$row['apellidos']."'>";
	echo "</div>";
	
	echo "<div>";
	echo "<label class='description' for='telefonover'>Tel&eacute;fono: </label>";
	echo "<input id='telefonover'  disabled  type='text'  size='50' value='".$row['telefono']."'>";
	echo "</div>";
	
	echo "<div>";
	echo "<label class='description' for='telefonover2'>M&oacute;vil: </label>";
	echo "<input id='telefonover2'  disabled  type='text' size='50' value='".$row['telefono_movil']."'>";
	echo "</div>";
	
	echo "<div>";
	echo "<label class='description' for='emailver'>Email: </label>";
	echo "<input id='emailver' disabled type='text'  size='50' value='".$row['email']."'>";
	echo "</div>";
	echo "<div>";
	echo "<label class='description' for='motivo'>Motivo de llamada: </label>";
	echo "<textarea rows='4' cols='38' id='motivo'></textarea>";
	echo "</div>";
	
	echo "<div>";
	echo "<label class='description' for='nota'>Observaci&oacute;n: </label>";
	echo "<textarea rows='4' cols='38' id='nota'></textarea>";
	echo "</div>";
	echo "<div>";
	
	echo "<fieldset style='font-size:20px;'>";
	echo "<legend>LLamada satisfactoria </legend>";
	echo "<label><input id='util'  type='radio' name='util' checked><font size='4'>S&iacute;</font></label>";
	echo "<br><label><input id='util'  type='radio' name='util'><font size='4'>No</font></label>";
	echo "</fieldset>";
	echo "<br>";
	
	
	echo    "</div>";
	echo 	"<div>";
	echo 	"<button type='button' class='btn btn-link btn-xs'  onclick='guardarLlamada(".$row['idclientes'].")'><span class='glyphicon glyphicon-floppy-disk'></span><font size='3'> Guardar info de llamada</font></button>";
	echo    "<button type='button' class='btn btn-link btn-xs'  onclick='regresar(".$deDonde.")'><span class='glyphicon glyphicon-arrow-left'></span><font size='3'> Regresar</font></button>";
	echo 	"</div>";
	echo   "</li>";
	echo   "</ul>";
	echo   "</form>";
	echo   "</td>";
	echo   "</tr>";
	echo   "</tbody>";
	echo   "</table>";
		
	mysql_close();
}
?>